package com.boot.unity.api.modules.rzgjj;

import com.alibaba.fastjson.JSONObject;
import com.boot.unity.api.common.AES;
import com.boot.unity.api.modules.rzgjj.controller.GjjController;
import com.boot.unity.api.modules.rzgjj.service.GjjSeachLogService;
import com.boot.unity.api.modules.rzgjj.service.GjjService;
import com.boot.unity.api.utils.IpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.StringUtils;

import java.time.LocalDateTime;

@Configuration
@EnableScheduling
public class TestTaskRunner {

    @Autowired
    private GjjService gjjService;

    @Autowired
    private GjjSeachLogService gjjSeachLogService;

    // @Scheduled(fixedRate=12*5*60000)
    public void test2(){
        System.out.println("执行了-----BLS002接口数据");

        String ipAddr = "127.0.0.1";
        String agrcode = "911C0000424618";// json.getString("agrcode");
        String begindate = "20230701";//day_id.split("'and'")[0];//json.getString("begindate");
        String enddate = "20240708";//day_id.split("'and'")[1];//json.getString("enddate");
//        JSONObject resultJson = gjjService.queryBLS002(cardcode,pername,agrcode,begindate,enddate,pageSize,currentPage,codetype);
        JSONObject resultJson = gjjService.queryBLS002ForY("","",agrcode,begindate,enddate,100,1,"");
        System.out.println("resultJson:::::"+resultJson.toString());
        LocalDateTime nowDate = LocalDateTime.now();
//        log.error("请求地址："+ipAddr+",请求参数："+body+",服务器时间:"+ nowDate+",请求结果："+resultJson);
        gjjSeachLogService.insertAll("BLS002-2",ipAddr,"",resultJson.toString(),nowDate.toString());
    }


    // @Scheduled(fixedRate=12*5*60000)
    public void test3(){
        System.out.println("执行了-----BLS003接口数据");


        String ipAddr = "127.0.0.1";
        String agrcode = "911C0000424618";// json.getString("agrcode");
        String begindate = "20230701";//day_id.split("'and'")[0];//json.getString("begindate");
        String enddate = "20240708";//day_id.split("'and'")[1];//json.getString("enddate");



        JSONObject resultJson = gjjService.queryBLS003("","",agrcode,begindate,enddate,100,1,"");
        System.out.println("resultJson:::::"+resultJson.toString());
        LocalDateTime nowDate = LocalDateTime.now();
//        log.error("请求地址："+ipAddr+",请求参数："+body+",服务器时间:"+ nowDate+",请求结果："+resultJson);
        gjjSeachLogService.insertAll("BLS003-3",ipAddr,"",resultJson.toString(),nowDate.toString());

    }

}
